home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-03-19 | 7.4 KB | 211 lines | [TEXT/MPS ] |
- # ****************************************************************************
- #
- # File Name: OnTargetOperations.Lib
- #
- # Contains: Tasks which extend the basic functionality of the OnTarget.lib.
- #
- # Written by: KTA
- #
- # Copyright: © 1993-1997 by Apple Computer, Inc., all rights reserved.
- #
- # ****************************************************************************
- # C h a n g e H i s t o r y (most recent first):
- # ****************************************************************************
- #
- # Vers Date Author Description
- # ---- -------- ------ ---------------------------------------------
- # 1.2.1 02/12/97 JAS Added 'vers' resources to library.
- # These should always match tool version when tool is revved.
- # <7> 2/28/95 ML marked
- # <6> 2/16/95 KTA _OnTarget() - Replaced with standard new version of standard
- # template which fixes some problems.
- # <5> 1/19/95 KTA Changed the name of ExceptionHandler() to ExceptionDispatcher().
- # <4> 1/13/95 KTA _Ontarget() - Added support for calling tasks as well as
- # services.
- # <3> 12/12/94 KTA _OnTarget()- changed match[target] to match[mouse].
- # <2> 12/12/94 KTA Added _OnTarget().
- # <1> 3/28/94 KTA Created - first checked in.
- #
- # ****************************************************************************
- #
-
- ########################################################################
- # External libraries
- #=======================================================================
- Libraries "OnTarget.Lib", "ExceptionHandling.Lib";
-
- #########################################################################
- # _OnTarget(pServiceOrTask, pParamList, pOnTarget, pIsRetry)
- #========================================================================
- # Author: KTA
- # Description: Does the exception handling for the OnTarget. All high level tasks
- # should call this routine for OnTarget tool services.
- # Handles initialization of tool automatically.
- # Parameters: pServiceOrTask - Name of the Service
- # pParamList - List of parameters
- # pOnTarget - Flag to indicate whether the service should be performed
- # the host or the target. 1 = target/0 = host.
- # Returns: What ever the OnTarget returns - list of three elements
- # { errCode, Data, [error message]}
- # Examples: _OnTarget('Initialize', {1});
- # Assumptions: None
- #========================================================================
- # History:
- # KTA 12/12/94 Created
- # KTA 1/13/95 Added support for calling tasks as well as services.
- # KTA 2/16/95 coerce pOnTarget to be either true or false, Temporarily
- # turn commandexceptions off, check scripterror, reset
- # commandexceptions, and if necessary throw scripterror
- #########################################################################
- TASK _OnTarget(pServiceOrTask, pParamList := {}, pOnTarget := true, pIsRetry := 0)
- begin
- Try
- begin
- returnVal := undefined;
- ParamType := TypeOf(pServiceOrTask);
-
- if (ParamType = 'string') # Service Call
- begin
- if (pOnTarget)
- pOnTarget := true;
- else
- pOnTarget := false;
- if not(global gOnTargetInitFlag = pOnTarget)
- begin
- try
- begin
- temp := CommandExceptions(0);
- OnTargetInit := OnTarget("Initialize", pOnTarget ); # initialize OnTarget
- InitError := Scripterror();
- CommandExceptions(temp);
- if (OnTargetInit[1] <> 0) # If error
- begin
- println "OnTarget error ( ", OnTargetInit[1], ", ", OnTargetInit[3] , " )";
- gOnTargetInitFlag := undefined;
- if (CommandExceptions())
- throw InitError;
- return(OnTargetInit);
- end;
- else
- gOnTargetInitFlag := pOnTarget;
- end;
- catch theErr
- begin
- ExceptionDispatcher(theErr);
- return(OnTargetInit);
- end;
- end;
-
- try
- begin
- NumParams := Card(pParamList);
- switch NumParams
- begin
- case 0: # 0 parameters
- returnVal := OnTarget(pServiceOrTask);
- case 1: # 1 parameter
- returnVal := OnTarget(pServiceOrTask, pParamList[1]);
- case 2: # 2 parameters
- returnVal := OnTarget(pServiceOrTask, pParamList[1], pParamList[2]);
- case 3: # 3 parameters
- returnVal := OnTarget(pServiceOrTask, pParamList[1], pParamList[2], pParamList[3]);
- case 4: # 4 parameters
- returnVal := OnTarget(pServiceOrTask, pParamList[1], pParamList[2], pParamList[3], pParamList[4]);
- case 5: # 5 parameters
- returnVal := OnTarget(pServiceOrTask, pParamList[1], pParamList[2], pParamList[3], pParamList[4], pParamList[5]);
- case 6: # 6 parameters
- returnVal := OnTarget(pServiceOrTask, pParamList[1], pParamList[2], pParamList[3], pParamList[4], pParamList[5], pParamList[6]);
- default: # error
- println "Error - unsupported number of parameters - {NumParams}";
- end;
-
- if (returnVal[1] <> 0) # If error
- begin
- if(returnVal[1] = -1) and not (pIsRetry) # Not initialized, and haven't retried already
- begin
- global gOnTargetInitFlag := undefined;
- returnVal := _OnTarget(pServiceOrTask, pParamList, pOnTarget, 1);
- end;
- end;
- else if(pServiceOrTask = 'Quit') # Reset the global gOnTargetInitFlag when we quit
- global gOnTargetInitFlag := undefined;
-
- end;
- catch theErr
- begin
- if(theErr = -1220) and not (pIsRetry)
- begin
- global gOnTargetInitFlag := undefined;
- returnVal := _OnTarget(pServiceOrTask, pParamList, pOnTarget, 1);
- end;
- else
- exceptionDispatcher(theErr);
- end;
- end;
- else if(ParamType = 'task')
- begin
- NumParams := Card(pParamList);
- switch NumParams
- begin
- case 0: # 0 parameters
- returnVal := call (pServiceOrTask);
- case 1: # 1 parameter
- returnVal := call (pServiceOrTask, pParamList[1]);
- case 2: # 2 parameters
- returnVal := call (pServiceOrTask, pParamList[1], pParamList[2]);
- case 3: # 3 parameters
- returnVal := call (pServiceOrTask, pParamList[1], pParamList[2], pParamList[3]);
- case 4: # 4 parameters
- returnVal := call (pServiceOrTask, pParamList[1], pParamList[2], pParamList[3], pParamList[4]);
- case 5: # 5 parameters
- returnVal := call (pServiceOrTask, pParamList[1], pParamList[2], pParamList[3], pParamList[4], pParamList[5]);
- case 6: # 6 parameters
- returnVal := call (pServiceOrTask, pParamList[1], pParamList[2], pParamList[3], pParamList[4], pParamList[5], pParamList[6]);
- default: # error
- println "Error - unsupported number of parameters - {NumParams}";
- end;
- end;
-
- if(pOnTarget) # To cause target errors to throw if Xtools are called
- match[mouse];
-
- return(returnVal);
- end;
- Catch theError
- ExceptionDispatcher(theError);
- end;
-
-
- #########################################################################
- # OnTargetInit()
- #========================================================================
- #
- # Author: GS
- #
- # Description: Initializes OnTarget
- # Parameters: None
- # Returns: 1 - if OnTarget launched and initialized
- # 0 - if OnTarget could not launch
- #
- # Examples: OnTargetInit()
- #
- #========================================================================
- # History:
- # KTA 7/14/93 Changed error handling
- #########################################################################
- TASK OnTargetInit()
- begin
- returnVal := 0;
- IsError := _OnTarget('Initialize',{1});
- if(IsError[1]) # Some Error
- begin
- errorString := IsError[3];
- println "Ontarget initialization failed: ", errorString;
- end;
- else
- returnVal := 1;
-
- return (returnVal);
- end;
-
-